package com.company.meituan2021;

import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int len = s.length();
        int largeCharacter = 0;
        int smallCharacter = 0;
        for (int i = 0; i < len ; i++) {
            char c = s.charAt(i);
            if(c >= 'A' && c <= 'Z'){
                largeCharacter++;
            }else{
                smallCharacter++;
            }
        }
        int big = largeCharacter > smallCharacter ? largeCharacter:smallCharacter;
        int small = largeCharacter > smallCharacter ? smallCharacter:largeCharacter;
        int res = big - (len >> 1);

        System.out.println(res);
    }
}
